<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/views/include/taglib.jsp"%>
<html>
<head>
	<title>活动海报管理</title>
	<meta name="decorator" content="default"/>
	<script type="text/javascript">
		$(document).ready(function() {
			$("#name").focus();
			$("#inputForm").validate({
				submitHandler: function(form){
					loading('正在提交，请稍等...');
					form.submit();
				},
				errorContainer: "#messageBox",
				errorPlacement: function(error, element) {
					$("#messageBox").text("输入有误，请先更正。");
					if (element.is(":checkbox")||element.is(":radio")||element.parent().is(".input-append")){
						error.appendTo(element.parent().parent());
					} else {
						error.insertAfter(element);
					}
				}
			});
		});
		
		function showPhoto(path){
			$("#picUrl").val(path);
			$("#photo").css("display", "block");
			var imageSrc = '${ctx}/download?filePath='+path;
			$("#photo").attr("src", imageSrc);
		}
	</script>
</head>
<body>
	<ul class="nav nav-tabs">
		<li class="active"><a href="${ctx}/ivm/activity/poster/form">活动海报</a></li>
	</ul><br/>
	<form:form id="inputForm" modelAttribute="activityPoster" action="${ctx}/ivm/activity/poster/save" method="post" class="form-horizontal">
		<form:hidden path="id"/>
		<form:hidden path="merchant.id"/>
		<tags:message content="${message}"/>
		<div class="control-group">
			<label class="control-label">活动名称:</label>
			<div class="controls">
				<form:input path="name" htmlEscape="false" maxlength="200" class="required"/>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">海报封面:</label>
			<div class="controls">
				<a href="javascript:" class="btn" id="photoUpload">上传图片</a><span style="color: red;">（建议尺寸为640x960）</span>
				<form:hidden path="picUrl" />
				<div class="actphoto" style="margin-top: 10px">
					<c:if test="${activityPoster.id!=null}">
						<img id="photo" src="${ctx}/download?filePath=${activityPoster.picUrl }" style="width:200px; height:300px;" />
					</c:if>
					<c:if test="${activityPoster.id==null}">
						<img id="photo" src="" style="width:200px; height:300px;" />
					</c:if>
				</div>
			</div>
		</div>
		<div class="control-group">
			<label class="control-label">是否开放:</label>
			<div class="controls">
				<form:radiobuttons path="openState" items="${fns:getDictList('yes_no')}" itemLabel="label" itemValue="value" htmlEscape="false" class="required" />
			</div>
		</div>
		<div class="form-actions">
			<shiro:hasPermission name="ivm:activity:poster:edit"><input id="btnSubmit" class="btn btn-primary" type="submit" value="保 存"/>&nbsp;</shiro:hasPermission>
			<input id="btnCancel" class="btn" type="button" value="返 回" onclick="history.go(-1)"/>
		</div>
	</form:form>
</body>
</html>
